import Vue from 'vue'
import VueRouter from 'vue-router'

/**
 * Extends Vue to use Vue Router
 */
Vue.use( VueRouter )

/**
 * Makes a new VueRouter that we will use to run all of the routes for the app.
 */
export default new VueRouter({
    routes: [
		{
			path: '/',
			name: 'home',
			component: Vue.component( 'Home', require( '~/App.vue' ).default )
		},
		{
			path: '/lead',
			name: 'lead',
			component: Vue.component( 'Lead', require( '~/Lead.vue' ).default )
		},		
		{
			path: '/introduce',
			name: 'introduce',
			component: Vue.component( 'Introduce', require( '~/Introduce.vue' ).default )
		},
		{
			path: '/bruteForce',
			name: 'bruteForce',
			component: Vue.component( 'BruteForce', require( '~/BruteForce.vue' ).default )
		},
		{
			path: '/pmt',
			name: 'pmt',
			component: Vue.component( 'PMT', require( '~/PMT.vue' ).default )
		},	
		{
			path: '/end',
			name: 'end',
			component: Vue.component( 'End', require( '~/End.vue' ).default )
		},
		{
			path: '/kmpNote',
			name: 'kmpNote',
			component: Vue.component( 'KMPNote', require( '~/KMPNote.vue' ).default ),
			props: (route) => ({ c: route.query.c == 'true'})
		},		
		{
			path: '/kmpVisualizer',
			name: 'kmpVisualizer',
			component: Vue.component( 'KMPVisualizer', require( '~/KMPVisualizer.vue' ).default )
		},
		{
			path: '/nextArrayNote',
			name: 'nextArrayNote',
			component: Vue.component( 'NextArrayNote', require( '~/NextArrayNote.vue' ).default ),
			props: (route) => {
				let c = null
				if (route.query.c == 'true')
					c = true
				else if (route.query.c == 'false')
					c = false
				
				return {
					c: c
				}
			}
		},
		{
			path: '/nextArrayVisualizer',
			name: 'nextArrayVisualizer',
			component: Vue.component( 'NextArrayVisualizer', require( '~/NextArrayVisualizer.vue' ).default )
		},
		{
			path: '/pmtToNextArray',
			name: 'pmtToNextArray',
			component: Vue.component( 'PMTToNextArray', require( '~/PMTToNextArray.vue' ).default )
		},
		{
			path: '/menuTree',
			name: 'menuTree',
			component: Vue.component( 'MenuTree', require( '~/components/MenuTree.vue' ).default )
		},
		{
			path: '/report',
			name: 'report',
			component: Vue.component( 'Report', require( '~/Report.vue' ).default )
		},
		{
			path: '/cardsHelp',
			name: 'cardsHelp',
			component: Vue.component( 'CardsHelp', require( '~/CardsHelp.vue' ).default )
		}
    ]
});

export function push(context, name) {
    return context.$router.push(name);
}